<?php

/**
 * Description of LinkSet
 *
 * @author user3
 */
class Ga_Db_LinkSet {

    protected $_links = array();

    public function addLink(Ga_Db_Link $link)
    {
        $this->_links[$link->getKey()] = $link;
    }

    public function getLink($keyLink)
    {
        if (isset($this->_links[$keyLink])) {
            return $this->_links[$keyLink];
        }
        return null;
    }

    public function findRowset($tableClassName)
    {
        foreach ($this->_links as $link) {
            if ($link->getParentRowset()->getTableClass() == $tableClassName) {
                return $link->getParentRowset();
            }

            if ($link->getDependentRowset()->getTableClass() == $tableClassName) {
                return $link->getDependentRowset();
            }
        }
        return null;
    }

}